Skip to content

refactor(agents): migrate code to hub (#1397, #1102)#1421

Merged
kovtcharov-amd merged 2 commits into
mainfrom
claudia/task-3da98ad0
Jun 4, 2026
Merged

refactor(agents): migrate code to hub (#1397, #1102)#1421
kovtcharov-amd merged 2 commits into
mainfrom
claudia/task-3da98ad0

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Why this matters

CodeAgent was baked into the core amd-gaia wheel, so it could only ship on the framework's release cycle and RoutingAgent hard-imported the entire code stack at module load. After this change, CodeAgent ships as an independent gaia-agent-code wheel (hub/agents/python/code/), discovered via the gaia.agent entry-point group like the other migrated agents. RoutingAgent stays in the framework and now resolves CodeAgent lazily through the registry (AgentRegistry().create_agent("code", ...)), so the core no longer depends on the code package — and fails loudly with an actionable install hint if the wheel is missing. Completes the code row of #1397 (legacy modernization) and #1102 (move production agents to hub/agents/).

Test plan

  • python util/lint.py --agents — clean (2 pre-existing docqa/emr warnings, unrelated)
  • python util/lint.py --black --isort --fix — clean; black --check hub/agents/python/code/ clean
  • uvx pylint src/gaia -E --rcfile .pylintrc --disable C0103,C0301,W0246,W0221,E1102,R0401,E0401,W0718,W0212 — clean (only the ignorable Windows os.geteuid E1101)
  • Framework decoupling: pytest tests/unit/agents/test_routing_agent.py tests/unit/agents/test_registry.py tests/unit/test_agent_required_connectors.py tests/unit/test_errors.py tests/unit/test_code_index_mixin.py — 144 passed
  • Migrated package (gated subset, mirrors test_code_agent.yml): pytest hub/agents/python/code/tests/test_code_agent_mixins.py hub/agents/python/code/tests/test_code_agent.py::TestCodeAgent -k "not workflow and not integration and not process_query" + validators + guardrails + TestCodeAgentIntegration — green
  • gaia_agent_code.build_registration() returns id=code, source=installed, namespaced_agent_id=installed:code; gaia-code console script resolves to gaia_agent_code.cli:main
  • tests/test_api.py + tests/mcp/test_agent_mcp_server.py collect with no import errors (api_registry change is docstring-only)
  • Repo-wide grep: no stale gaia.agents.code imports remain (the two gaia/agents/code strings in errors.py FRAMEWORK_PATHS are intentionally kept, matching the jira/blender/docker migrations)

Notes for the reviewer

  • tests/unit/cli/test_cli_smoke.py may show a stale gaia-code -> gaia.agents.code.cli entry only in a dev environment with a previously editable-installed amd-gaia (the documented worktree gotcha). A clean install picks up the updated setup.py (no gaia-code) and passes.
  • A few pre-existing, non-gated code tests still fail offline (Context7 service in test_external_tools, run_npm_command registry drift in test_typescript_tools, process_query LLM tests, and hasattr assertions in the ungated test_sdk code-mixin checks). All were verified to fail identically on main; fixing them is out of scope for this migration.

CodeAgent had been baked into the core amd-gaia wheel, so it could only ship
on the framework's release cycle and any RoutingAgent import dragged the whole
code stack into the core. CodeAgent now ships as the standalone gaia-agent-code
wheel under hub/agents/python/code/, discovered via the gaia.agent entry-point
group; RoutingAgent stays in the framework and resolves it lazily through the
registry, so the core no longer hard-depends on it.

- Move src/gaia/agents/code/ -> hub/agents/python/code/gaia_agent_code/ with
  build_registration(), pyproject (gaia-code console script), gaia-agent.yaml,
  and README mirroring the jira package.
- RoutingAgent uses AgentRegistry().create_agent("code", ...) and raises a
  loud, actionable error when the wheel is absent (no silent fallback).
- setup.py: drop code packages + the gaia-code console script; add the
  agent-code extra and code to [agents].
- Move code-specific tests into the package; test_sdk gates them via
  pytest.importorskip("gaia_agent_code"); restore the write-guardrail tests'
  tool accessor so that coverage runs again.
- Update test_code_agent.yml to install the wheel and run from the new paths;
  drop gaia-code from the amd-gaia publish smoke check.
@github-actions github-actions Bot added documentation Documentation changes dependencies Dependency updates devops DevOps/infrastructure changes code-agent Code agent changes tests Test changes agents labels Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Code Review — refactor(agents): migrate code to hub (#1397, #1102)

Summary

Clean, mechanical migration that does exactly what the description promises: CodeAgent leaves the core amd-gaia wheel for a standalone gaia-agent-code package under hub/agents/python/code/, and RoutingAgent resolves it lazily through the registry instead of hard-importing it. The single most important thing: the decoupling is implemented correctly and fails loudlyRoutingAgent._build_code_agent checks registry.get("code") and raises an actionable install hint when the wheel is missing (routing/agent.py:496), which is exactly what the No-Silent-Fallbacks rule asks for. The new __init__.py / pyproject.toml are near-identical to the already-merged docker migration, so the package shape is consistent with precedent. I verified the registry API (discover / get / create_agent), confirmed the AgentRegistry(); discover() pattern matches cli_agent._build_registry, that no stale gaia.agents.code imports remain in src/ (only the intentional errors.py FRAMEWORK_PATHS), that the referenced docs/spec/agent-hub-restructure.mdx exists, and that min_gaia_version/amd-gaia>=0.20.0 match the current 0.20.0.

No prompt injection observed in the diff or description.

Issues Found

🟢 Minor — tools_count: 0 is inaccurate (hub/agents/python/code/gaia-agent.yaml:11, gaia_agent_code/__init__.py:822)
CodeAgent composes 15+ tool mixins (agent.py:64), so tools_count: 0 understates it in any hub listing UI that reads this metadata. This matches the existing docker/jira/blender placeholder, so it's not a regression introduced here — flagging only so it's tracked for hub display accuracy across all migrated agents, not as a blocker for this PR.

🟢 Minor — discover() re-runs on every routed code task (src/gaia/agents/routing/agent.py:489)
_build_code_agent builds a fresh AgentRegistry() and calls discover() each time, which rescans entry points. This mirrors the established cli_agent._build_registry pattern so it's consistent and fine for the once-per-route path — noting only in case a shared/cached registry is preferred later.

Strengths

  • Decoupling is the right shape. Removing the module-load hard import and resolving via AgentRegistry().create_agent("code", ...) means the core no longer depends on the code stack, and the missing-wheel path raises a clear, actionable RuntimeError rather than an opaque ImportError.
  • Coherent, complete migration. setup.py (package list + gaia-code script + agent-code extra), publish.yml CLI-verify, test_code_agent.yml path filters, CLAUDE.md, and all docs/spec/* import references were updated together — and the repo is grep-clean of stale gaia.agents.code imports.
  • Test handling is careful, not just moved. pytest.importorskip("gaia_agent_code") gates the in-framework test_sdk checks, the routing test now mocks the registry instead of the concrete class, and the guardrail tests' _TOOL_REGISTRY[...]["function"] correction (test_file_io_guardrails.py:54) fixes a real registry-shape access that the shared verify_path_validator.py already used.

Verdict

Approve with suggestions. No blocking issues. The two minor notes are non-blocking and partly inherited from prior migrations; safe to merge. Nice, disciplined refactor that stays consistent with the docker/jira/blender precedent.

@kovtcharov-amd kovtcharov-amd merged commit d5e606a into main Jun 4, 2026
55 of 56 checks passed
@kovtcharov-amd kovtcharov-amd deleted the claudia/task-3da98ad0 branch June 4, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents code-agent Code agent changes dependencies Dependency updates devops DevOps/infrastructure changes documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant